package com.orange.controller.expert;

import java.io.File;
import java.io.FileInputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.orange.controller.BaseController;
import com.orange.dbhelp.page.Page;
import com.orange.handler.AuthExpertService;
import com.orange.handler.AuthExportGroupMapService;
import com.orange.handler.AuthExportGroupService;
import com.orange.handler.AuthItemService;
import com.orange.handler.AuthSchoolService;
import com.orange.handler.AuthSubjectService;
import com.orange.handler.expert.AuthCityService;
import com.orange.handler.expert.AuthExamExpertMapService;
import com.orange.handler.expert.AuthExamService;
import com.orange.handler.expert.AuthExportTaskMapService;
import com.orange.handler.expert.AuthGroupService;
import com.orange.handler.expert.AuthIinspectionOpinionsService;
import com.orange.handler.expert.AuthObservationEvaluationService;
import com.orange.handler.expert.AuthSpecialTaskService;
import com.orange.modules.bean.MeterialResultBean;
import com.orange.modules.bean.SessionUser;
import com.orange.modules.bean.expert.ExpertTaskBean;
import com.orange.modules.entity.AuthItem;
import com.orange.modules.entity.expert.AuthExam;
import com.orange.modules.entity.expert.AuthExamExpertMap;
import com.orange.modules.entity.expert.AuthExpert;
import com.orange.modules.entity.expert.AuthExportGroupMap;
import com.orange.modules.entity.expert.AuthExportTaskMap;
import com.orange.modules.entity.expert.AuthGroup;
import com.orange.modules.entity.expert.AuthIinspectionOpinions;
import com.orange.modules.entity.expert.AuthObservationEvaluation;
import com.orange.modules.entity.expert.AuthSpecialTask;
import com.orange.modules.entity.manage.AuthCity;
import com.orange.modules.entity.manage.AuthSubject;
import com.orange.modules.entity.school.AuthSchool;
import com.orange.util.AppConfig;
import com.orange.util.Hash;
import com.orange.util.ReturnCode;

/**
 * 现场考察专家
 * @author gaogs
 *
 * 2016-12-12
 */
@Controller
@RequestMapping("/expert")
public class AuthObservationExpertController extends BaseController{
	
	private static final Logger logger = Logger.getLogger(AuthObservationExpertController.class);
	
	@Autowired
	private AuthExpertService authExpertService;
	
	@Autowired
	private AuthItemService authItemService;
	
	@Autowired
	private AuthSpecialTaskService authSpecialTaskService;
	
	@Autowired
	private AuthExportGroupMapService authExportGroupMapService;
	
	@Autowired
	private AuthExportTaskMapService authExportTaskMapService;
	
	@Autowired
	private AuthGroupService authGroupService;
	
	@Autowired
	private AuthSchoolService authSchoolService;
	
	@Autowired
	private AuthExamService authExamService;
	
	@Autowired
	private AuthExamExpertMapService authExamExpertMapService;
	
	@Autowired
	private AuthObservationEvaluationService authObservationEvaluationService;
	
	@Autowired
	private AppConfig appconfig;
	
	@Autowired
	private AuthIinspectionOpinionsService authIinspectionOpinionsService;
	
	@Autowired
	private AuthCityService authCityService;
	
	@Autowired
	private AuthExportGroupService authExportGroupService;
	
	@Autowired
	private AuthSubjectService authSubjectService;
	
	/**
	 * 查询所有的城市
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/queryAuthCityAll" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthCityAll(HttpServletRequest request) throws SQLException{
		
		try {
			List<AuthCity> list=authCityService.queryAuthCityAll();
			return toResponse(list,ReturnCode.SUCCESS,"查询所有的城市成功");
		} catch (Exception e) {
			logger.info("查询所有的城市失败",e);
			return toResponse(null,ReturnCode.FAIL,"查询所有的城市失败");
		}
		
	}
	
	/**
	 * 新增专家
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/insertAuthExpert" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> insertAuthExpert(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			AuthExpert authExpert  = new AuthExpert();
			String expertcode = map.get("expertcode");
			String expertname = map.get("expertname");
			String title = map.get("title");
			String post = map.get("post");
			String field = map.get("field");
			String officephone = map.get("officephone");
			String phone = map.get("phone");
			String email = map.get("email");
			String workunit = map.get("workunit");
			String academy = map.get("academy");
			String department = map.get("department");
			String sex = map.get("sex");
			String birthday = map.get("birthday");
			String degree = map.get("degree");
			String subject = map.get("subject");
			String city = map.get("city");
			String password = "123456"; //默认密码
			String speciality = map.get("speciality");
			String parttime = map.get("parttime");
			String fax = map.get("fax");
			String type = map.get("type");
			if(StringUtils.isBlank(expertcode) || expertcode==null)
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专家编号不能为空!");
			if(StringUtils.isBlank(expertname) || expertname==null)
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专家姓名不能为空!");
			
			AuthExpert ae = authExpertService.queryExpertByAccount(expertcode);
			if(ae!=null)
				return toResponse(null,ReturnCode.FAIL,"该账号已存在!");
			authExpert.setAcademy(academy);
			authExpert.setBirthday(birthday);
			authExpert.setCity(city);
			authExpert.setCreatetime(sdf.format(new Date()));
			authExpert.setDegree(degree);
			authExpert.setDepartment(department);
			authExpert.setEmail(email);
			authExpert.setExpertcode(expertcode);
			authExpert.setExpertname(expertname);
			authExpert.setFax(fax);
			authExpert.setField(field);
			authExpert.setOfficephone(officephone);
			authExpert.setParttime(parttime);
			authExpert.setPassword(Hash.sha2InHex(password));
			authExpert.setPhone(phone);
			authExpert.setPost(post);
			authExpert.setSex(sex);
			authExpert.setSpeciality(speciality);
			authExpert.setSubject(subject);
			authExpert.setTitle(title);
			authExpert.setType(type);
			authExpert.setWorkunit(workunit);
			authExpert.setStatus("0");
			authExpert.setStatuss("0");
			authExpertService.insertAuthExpert(authExpert);
			return toResponse(authExpert,ReturnCode.SUCCESS,"新增专家成功");
		} catch (Exception e) {
			logger.info("新增专家失败",e);
			return toResponse(null,ReturnCode.FAIL,"新增专家失败");
		}
		
	}
	
	/**
	 * 删除专家
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/deleteAuthExpert" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> deleteAuthExpert(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		
		try {
			String pid = map.get("pid");
			if(StringUtils.isBlank(pid))
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"pid不能为空!");
			
			AuthExpert a=authExpertService.queryAuthExpertInfoById(pid);
			if(null==a){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该专家信息不存在");
			}
			if("1".equals(a.getStatus())||"1".equals(a.getStatuss())){
				return toResponse(null,ReturnCode.SCHOOL_HAVE_COLLEC,"该专家已被绑定专家组不可删除");
			}
			authExpertService.deleteAuthExpert(pid);
			return toResponse(null,ReturnCode.SUCCESS,"删除专家成功");
		} catch (Exception e) {
			logger.info("删除专家失败",e);
			return toResponse(null,ReturnCode.FAIL,"删除专家失败");
		}
		
	}
	
	
	/**
	 * 查询专家列表
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/queryAuthExpert" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpert(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		
		try {
			String pageNumber = map.get("pageNumber");
			String pageSize = map.get("pageSize");
			if(StringUtils.isBlank(pageNumber)||StringUtils.isBlank(pageSize)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			Page<AuthExpert> page = authExpertService.queryAllExpert(Integer.valueOf(pageNumber) , Integer.valueOf(pageSize), map);
			return toResponse(page,ReturnCode.SUCCESS,"查询成功");
		} catch (NumberFormatException e) {
			e.printStackTrace();
			return toResponse(null,ReturnCode.FAIL,"查询失败");
		}
	}
	
	
	/**
	 * 修改专家信息
	 */
	@RequestMapping(value = "/updateAuthExpert" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> updateAuthExpert(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		try{
			String pid = map.get("pid");
			String expertcode = map.get("expertcode");
			String expertname = map.get("expertname");
			String title = map.get("title");
			String post = map.get("post");
			String field = map.get("field");
			String officephone = map.get("officephone");
			String phone = map.get("phone");
			String email = map.get("email");
			String workunit = map.get("workunit");
			String academy = map.get("academy");
			String department = map.get("department");
			String sex = map.get("sex");
			String birthday = map.get("birthday");
			String degree = map.get("degree");
			String subject = map.get("subject");
			String city = map.get("city");
			String speciality = map.get("speciality");
			String parttime = map.get("parttime");
			String fax = map.get("fax");
			String type = map.get("type");
			AuthExpert ae = authExpertService.queryAuthExpertInfoById(pid);
			if(null==ae){
				return toResponse(ae,ReturnCode.FAIL,"专家信息不存在");
			}
			if(StringUtils.isNotBlank(expertcode))
				ae.setExpertcode(expertcode);
			if(StringUtils.isNotBlank(expertname))
				ae.setExpertname(expertname);
			ae.setTitle(title);
			ae.setPost(post);
			ae.setField(field);
			ae.setOfficephone(officephone);
			ae.setPhone(phone);
			ae.setEmail(email);
			ae.setWorkunit(workunit);
			ae.setAcademy(academy);
			ae.setDepartment(department);
			ae.setSex(sex);
			ae.setBirthday(birthday);
			ae.setDegree(degree);
			ae.setSubject(subject);
			ae.setCity(city);
			ae.setSpeciality(speciality);
			ae.setParttime(parttime);
			ae.setFax(fax);
			ae.setType(type);
			authExpertService.insertAuthExpert(ae);
			return toResponse(ae,ReturnCode.SUCCESS,"修改成功");
		}catch(Exception e){
			logger.error(e);
			return toResponse(null,ReturnCode.FAIL,"修改失败");
		}
	}

/*	*//**
	 * 根据姓名 城市 学科查询专家
	 *//*
	@RequestMapping(value = "/queryAuthExpertByInfoPge" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertByInfoPge(HttpServletRequest request,@RequestBody Map<String ,String> map){
		try{
			String pageNumber = map.get("pageNumber");
			String pageSize = map.get("pageSize");
			if(pageNumber == null || StringUtils.isBlank(pageNumber))
				return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "不可为空");
			if(pageSize == null || StringUtils.isBlank(pageSize))
				return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "不可为空");
			Page<AuthExpert> page = authExpertService.queryExpertByInfoPage(map);
			return toResponse(page, ReturnCode.SUCCESS,"查询成功");
		}catch(SQLException e){
			logger.error(e);
			return toResponse(null, ReturnCode.FAIL, "查询失败");
		}
	}*/
	
	/**
	 * 修改密码
	 */
	@RequestMapping(value="/updatePass" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> updatePass(HttpServletRequest request,HttpServletResponse response ,@RequestBody Map<String ,String> map){
		
		
		try {
			String pid = map.get("pid");
			if(StringUtils.isBlank(pid)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专家id不可为空");
			}
			String password = map.get("oldpassword");
			if(StringUtils.isBlank(password)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"原密码不可为空");
			}
			String newpass1 = map.get("newpassword1");
			if(StringUtils.isBlank(newpass1)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"新密码不可为空");
			}
			String newpass2 = map.get("newpassword2");
			if(StringUtils.isBlank(newpass2)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"二次密码为空");
			}
			if(!newpass1.equals(newpass2)){
				return toResponse(null,ReturnCode.PASSWOED_IS_FALSE,"两次密码不一致");
			}
			AuthExpert ae  = authExpertService.queryAuthExpertInfoById(pid);
			if(null==ae){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"用户信息不存在");
			}
			String newPassw=Hash.sha2InHex(password);
			if(!newPassw.equals(ae.getPassword())){
				return toResponse(null,ReturnCode.USERNAME_OR_PASSWORD_FALSE,"原密码错误");
			}
			String newp = Hash.sha2InHex(newpass1);
			ae.setPassword(newp);
			authExpertService.updateAuthExpert(ae);
			return toResponse(ae,ReturnCode.SUCCESS,"密码修改成功");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null, ReturnCode.FAIL, "密码修改失败");
		}
	}
	
	
	
	/**
	 * 根据session修改
	 */
	@RequestMapping(value = "/updateAuthExpertBySessionId" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> updateAuthExpertBySessionId(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		try{
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExpert ae = authExpertService.queryAuthExpertInfoById(pid);
			if(null==ae){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"专家信息不存在");
			}
			if("0".equals(map.get("type"))){
				ae.setTitle(map.get("title"));
				ae.setPost(map.get("post"));
				ae.setField(map.get("field"));
				ae.setOfficephone(map.get("officephone"));
				ae.setPhone(map.get("phone"));
				ae.setEmail(map.get("email"));
				ae.setWorkunit(map.get("workunit"));
				ae.setAcademy(map.get("academy"));
				ae.setDepartment(map.get("department"));
				ae.setSex(map.get("sex"));
				ae.setBirthday(map.get("birthday"));
				ae.setDegree(map.get("degree"));
				ae.setSubject(map.get("subject"));
				ae.setCity(map.get("city"));
				ae.setSpeciality(map.get("speciality"));
				ae.setParttime(map.get("parttime"));
				ae.setFax(map.get("fax"));
				ae.setType(map.get("type"));
				authExpertService.insertAuthExpert(ae);
			}
			if("1".equals(map.get("type"))){
				ae.setWorkunit(map.get("workunit"));
				ae.setTitle(map.get("title"));
				ae.setPost(map.get("post"));
				ae.setSpeciality(map.get("speciality"));
				ae.setParttime(map.get("parttime"));
				ae.setSubject(map.get("subject"));
				ae.setCity(map.get("city"));
				ae.setOfficephone(map.get("officephone"));
				ae.setPhone(map.get("phone"));
				ae.setFax(map.get("fax"));
				authExpertService.insertAuthExpert(ae);
			}
			return toResponse(ae,ReturnCode.SUCCESS,"修改成功");
		}catch(Exception e){
			logger.error(e);
			return toResponse(null,ReturnCode.FAIL,"修改失败");
		}
	}

	
	
	
	/**
	 * 通过session中的ID查找
	 * @param request
	 * @param response
	 * @param pid
	 * @return
	 */
	@RequestMapping(value="/queryAuthExpertInfoByOneId" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertInfoByOneId(HttpServletRequest request,HttpServletResponse response ){
		try {
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExpert ae = authExpertService.queryAuthExpertInfoById(pid);
			if(null==ae){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"专家信息不存在");
			}
			return toResponse(ae,ReturnCode.SUCCESS,"根据专家id查询专家信息成功");
		} catch (Exception e) {
			logger.info("根据专家id查询专家信息失败",e);
			return toResponse(null, ReturnCode.FAIL, "根据专家id查询专家信息失败");
		}
	}
	
	
	
	
	
	/**
	 * 根据专家id查询专家信息
	 * @param request
	 * @param response
	 * @param pid
	 * @return
	 */
	@RequestMapping(value="/queryAuthExpertInfoById" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertInfoById(HttpServletRequest request,HttpServletResponse response ,@RequestParam String pid){
		try {
			if(StringUtils.isBlank(pid)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数不可为空");
			}
			AuthExpert ae = authExpertService.queryAuthExpertInfoById(pid);
			if(null==ae){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"专家信息不存在");
			}
			return toResponse(ae,ReturnCode.SUCCESS,"根据专家id查询专家信息成功");
		} catch (Exception e) {
			logger.info("根据专家id查询专家信息失败",e);
			return toResponse(null, ReturnCode.FAIL, "根据专家id查询专家信息失败");
		}
	}
	
	
	/************************************************专家登录系统功能   联络员:分配任务**************************************************/
	
	
	/**
	 * 联络员分工  ：查询联络员当前组员信息
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryCurrentGroup" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryCurrentGroup(HttpServletRequest request,HttpServletResponse response,@RequestBody Map<String,String> map){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			String pageSize = map.get("pageSize");
			String pageNumber = map.get("pageNumber");
			if(StringUtils.isBlank(pageSize)||StringUtils.isBlank(pageNumber)){
				return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "参数存在空值");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"3".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察联络员不可进行此操作");
			}
			map.put("groupId", aa.getGroupId());
			Page<AuthExportGroupMap> ls=authExportGroupMapService.queryAuthExportGroupMapPage(map);
			return toResponse(ls,ReturnCode.SUCCESS,"查询联络员当前组员信息成功");
		} catch (Exception e) {
			logger.info("查询联络员当前组员信息失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询联络员当前组员信息失败");
		}
	}
	
	
	
	/**
	 * 联络员分工  ：查询所有一级指标
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryItem_one" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryItem_one(HttpServletRequest request,HttpServletResponse response,@RequestParam String expertId ){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"3".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察联络员不可进行此操作");
			}
			List<AuthExportTaskMap> authExportTaskMaps=authExportTaskMapService.queryAuthExportTaskMaps(aa.getGroupId(), expertId);
			Map<String ,String >map=new HashMap<String, String>();
			for(AuthExportTaskMap a:authExportTaskMaps){
				if("0".equals(a.getType())){
					map.put(a.getTaskId(), "1");
				}
			}
			
			List<AuthItem> ls=authItemService.queryAuthItemTwice("0");
			for(AuthItem a:ls){
				if(null==map.get(a.getPid())){
					a.setFlag("0");
				}else{
					a.setFlag("1");
				}
			}
			
			return toResponse(ls,ReturnCode.SUCCESS,"查询所有一级指标成功");
		} catch (Exception e) {
			logger.info("查询所有一级指标失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询所有一级指标失败");
		}
	}
	
	
	/**
	 * 联络员分工  ：查询所有专业技能  包括 ：必测  选测 和 其他任务
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryTask" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryTask(HttpServletRequest request,HttpServletResponse response,@RequestParam String expertId ){
		try {
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"3".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察联络员不可进行此操作");
			}
			List<AuthExportTaskMap> authExportTaskMaps=authExportTaskMapService.queryAuthExportTaskMaps(aa.getGroupId(), expertId);
			Map<String ,String >map=new HashMap<String, String>();
			for(AuthExportTaskMap a:authExportTaskMaps){
				if(!"0".equals(a.getType())){
					map.put(a.getTaskId(), "1");
				}
			}
			
			List<AuthSpecialTask> ls=authSpecialTaskService.queryAuthSpecialTaskinfoss();
			
			List<AuthSpecialTask> ls1=new ArrayList<AuthSpecialTask>();
			List<AuthSpecialTask> ls2=new ArrayList<AuthSpecialTask>();
			List<AuthSpecialTask> ls3=new ArrayList<AuthSpecialTask>();
			for(AuthSpecialTask a:ls){
				if(null==map.get(a.getPid())){
					a.setFlag("0");
				}else{
					a.setFlag("1");
				} 
				if("0".equals(a.getType())){
					ls1.add(a);
				}
				if("1".equals(a.getType())){
					ls2.add(a);
				}
				if("2".equals(a.getType())){
					ls3.add(a);
				}
			}
			Map<String,List<AuthSpecialTask>>maps=new HashMap<String, List<AuthSpecialTask>>();
			maps.put("0", ls1);
			maps.put("1", ls2);
			maps.put("2", ls3);
			return toResponse(maps,ReturnCode.SUCCESS,"查询所有专业技能成功");
		} catch (Exception e) {
			logger.info("查询所有专业技能失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询所有专业技能失败");
		}
	}
	
	/**
	 * 联络员分工  ：专家分工
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/divideWork" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryTask(HttpServletRequest request,HttpServletResponse response ,@RequestBody Map<String,String>map){
		try {
			String tasks_0=map.get("tasks_0");//一级指标 id  以','拼接
			String tasks_1=map.get("tasks_1");//必测专业技能任务id  以','拼接
			String tasks_2=map.get("tasks_2");//选测专业技能任务id  以','拼接
			String tasks_3=map.get("tasks_3");//其他专业技能任务id  以','拼接
			String expertId=map.get("expertId") ;//分配任务的专家id
			
			if(StringUtils.isBlank(tasks_0)&&StringUtils.isBlank(tasks_1)
					&&StringUtils.isBlank(tasks_2)&&StringUtils.isBlank(tasks_3)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			if(StringUtils.isBlank(expertId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"专家id不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"3".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察联络员不可进行此操作");
			}
			//查看该专家是否已填写数据
			AuthExportTaskMap aetm=authExportTaskMapService.queryAuthExportTaskByGroupAndExpertId(aa.getGroupId(), expertId);
			if(null!=aetm){
				return toResponse(null,ReturnCode.EXPERT_HAVE_DATA,"该专家已填报数据不可重新分配任务");
			}
			AuthIinspectionOpinions aio=authIinspectionOpinionsService.queryAuthIinspectionOpinionsLists(aa.getGroupId(), expertId);
			if(null!=aio){
				return toResponse(null,ReturnCode.EXPERT_HAVE_DATA,"该专家已填报数据不可重新分配任务");
			}
			AuthGroup ag=authGroupService.queryAuthGroupInfoById(aa.getGroupId());
			if(null==ag){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该现场考察专家组信息不存在");
			}
			AuthObservationEvaluation aoe=authObservationEvaluationService.queryAuthObservationEvaluationInfo(ag.getSchoolId(), expertId);
			if(null!=aoe){
				return toResponse(null,ReturnCode.EXPERT_HAVE_DATA,"该专家已填报数据不可重新分配任务");
			}
			
			//删除组内某专家任务
			authExportTaskMapService.deleteAuthExportTaskByExportInfo(aa.getGroupId(), expertId);
			
			List<AuthExportTaskMap> list=new ArrayList<AuthExportTaskMap>();
			String nowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			if(StringUtils.isNotBlank(tasks_0)){
				String[]tasks=tasks_0.split(",");
				if(tasks.length>0){
					for(int i=0;i<tasks.length;i++){
						AuthExportTaskMap a=new AuthExportTaskMap();
						a.setCreateTime(nowTime);
						a.setExportId(expertId);
						a.setGroupId(aa.getGroupId());
						a.setType("0");
						a.setTaskId(tasks[i]);
						list.add(a);
					}
				}
			}
			if(StringUtils.isNotBlank(tasks_1)){
				String[]tasks=tasks_1.split(",");
				if(tasks.length>0){
					for(int i=0;i<tasks.length;i++){
						AuthExportTaskMap a=new AuthExportTaskMap();
						a.setCreateTime(nowTime);
						a.setExportId(expertId);
						a.setGroupId(aa.getGroupId());
						a.setType("1");
						a.setTaskId(tasks[i]);
						list.add(a);
					}
				}
			}
			if(StringUtils.isNotBlank(tasks_2)){
				String[]tasks=tasks_2.split(",");
				if(tasks.length>0){
					for(int i=0;i<tasks.length;i++){
						AuthExportTaskMap a=new AuthExportTaskMap();
						a.setCreateTime(nowTime);
						a.setExportId(expertId);
						a.setGroupId(aa.getGroupId());
						a.setType("2");
						a.setTaskId(tasks[i]);
						list.add(a);
					}
				}
			}
			
			if(StringUtils.isNotBlank(tasks_3)){
				String[]tasks=tasks_3.split(",");
				if(tasks.length>0){
					for(int i=0;i<tasks.length;i++){
						AuthExportTaskMap a=new AuthExportTaskMap();
						a.setCreateTime(nowTime);
						a.setExportId(expertId);
						a.setGroupId(aa.getGroupId());
						a.setType("3");
						a.setTaskId(tasks[i]);
						list.add(a);
					}
				}
			}
			authExportTaskMapService.saveAuthExportTaskMapInfos(list);
			return toResponse(null,ReturnCode.SUCCESS,"专家分工成功");
		} catch (Exception e) {
			logger.info("专家分工失败",e);
			return toResponse(null, ReturnCode.FAIL, "专家分工失败");
		}
	}
	
	
	
	/*************************************************组长：抽题*********************************************/
	/**
	 * 判断该校专业
	 */
	@RequestMapping(value="/querymajor" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> querymajor(HttpServletRequest request,HttpServletResponse response){
		try {
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa;
				aa = authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"2".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察组长不可进行此操作");
			}
			AuthGroup ag=authGroupService.queryAuthGroupInfoById(aa.getGroupId());
			if(null==ag){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该现场考察专家组信息不存在");
			}
			AuthSchool school=authSchoolService.queryAuthSchoolInfoById(ag.getSchoolId());
			if(null==school){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"机构信息不存在");
			}
			
			return toResponse(school.getMajor(), ReturnCode.SUCCESS, "查询该校专业成功");
		}catch (SQLException e) {
			
			e.printStackTrace();
			return toResponse(null, ReturnCode.FAIL, "查询该校专业失败");
		}
	}
	
	/**
	 * 判断说课中学科的题库是否为空
	 */
	
	@RequestMapping(value="/querySubject" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> querySubject(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String taskId){
		try {
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			List<AuthSubject>lt = authSubjectService.queryAuthSubjectByExam(taskId);
			return toResponse(lt, ReturnCode.SUCCESS, "有题库的科目");
		} catch (SQLException e) {
			
			e.printStackTrace();
			return toResponse(null, ReturnCode.FAIL, "没有题库的科目");
		}
	}
	
	/**
	 * 组长抽题：根据专业技能id及科目查询试题
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryExamByTaskId" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryExamByTaskId(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String taskId,@RequestParam String subject){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"2".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察组长不可进行此操作");
			}
			AuthGroup ag=authGroupService.queryAuthGroupInfoById(aa.getGroupId());
			if(null==ag){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该现场考察专家组信息不存在");
			}
			AuthSchool school=authSchoolService.queryAuthSchoolInfoById(ag.getSchoolId());
			if(null==school){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"机构信息不存在");
			}
			List<AuthExam> ls = new ArrayList<AuthExam>();
			
			ls=authExamService.queryAuthExamListByTask(taskId,school.getMajor(), subject);
			
			return toResponse(ls,ReturnCode.SUCCESS,"根据专业技能id及科目查询试题成功");

		} catch (Exception e) {
			logger.info("根据专业技能id及科目查询试题失败",e);
			return toResponse(null, ReturnCode.FAIL, "根据专业技能id及科目查询试题失败");
		}
	}
	
	/**
	 * 组长抽题：保存抽取的试题
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/saveExams" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> saveExams(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String examId,@RequestParam String subjectId,@RequestParam String taskId){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportGroupMap aa=authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			if(null==aa||!"2".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察组长不可进行此操作");
			}
			if(StringUtils.isBlank(examId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"试题id为空");
			}
			AuthExam s=authExamService.queryAuthExamInfo(examId);
			if(null==s){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该试题不存在");
			}
			//List<AuthExportTaskMap> ls=authExportTaskMapService.queryAuthExportTaskMapByGroupAndTaskId(aa.getGroupId(), s.getTaskId());
			
			List<AuthExamExpertMap> list=new ArrayList<AuthExamExpertMap>();
			//if(ls.size()>0){
			List<AuthExamExpertMap>l=authExamExpertMapService.queryAuthExamExpertMapByTaskAndSubject(aa.getGroupId(), s.getTaskId(), s.getSubject());
			if(l.size()>0){
				authExamExpertMapService.deleteAuthExamExpertMapInfos(l);
			}
			
			String nowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				//for(AuthExportTaskMap a:ls){
			AuthExamExpertMap aee=new AuthExamExpertMap();
			aee.setCreateTime(nowTime);
			aee.setExamId(examId);
			aee.setExpertId(pid);
			aee.setGroupId(aa.getGroupId());
			list.add(aee);
				//}
			//}
			authExamExpertMapService.saveAuthExamExpertMapInfos(list);
			
			if(taskId != null){
				AuthSpecialTask st = authSpecialTaskService.queryAuthSpecialTaskInfoById(taskId);
				if(st.getRemark().equals("0")){
					st.setState("2");
					authSpecialTaskService.saveAuthSpecialTaskInfo(st);
				}else{ 
					if(subjectId != null){
						AuthSubject as = authSubjectService.queryAuthSubjectByPId(subjectId);
						as.setState("2");
						authSubjectService.updataAuthSubject(as);
					}
				}
			}
			return toResponse(null,ReturnCode.SUCCESS,"保存抽取的试题成功");
		} catch (Exception e) {
			logger.info("保存抽取的试题失败",e);
			return toResponse(null, ReturnCode.FAIL, "保存抽取的试题失败");
		}
	}
	
	
	
	/**************************************************课堂观摩************************************************/
	
	
	/**
	 * 查询课堂观摩学校列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthExpertObservationPage" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertObservationPage(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String> map){
		try {
			if(StringUtils.isBlank(map.get("pageSize"))||StringUtils.isBlank(map.get("pageNumber"))){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"分页参数不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			Page<AuthSchool> ls=authSchoolService.queryAuthSchoolAndObservation(pid,map);
			return toResponse(ls,ReturnCode.SUCCESS,"查询课堂观摩学校列表成功");
		} catch (Exception e) {
			logger.info("查询课堂观摩学校列表失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询课堂观摩学校列表失败");
		}
	}
	
	/**
	 * 查询专家课堂观摩填报信息
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthExpertObservationInfo" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertObservationInfo(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String schoolId){
		try {
			String userId=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==userId){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthObservationEvaluation a=authObservationEvaluationService.queryAuthObservationEvaluationInfo(schoolId, userId);
			return toResponse(a,ReturnCode.SUCCESS,"查询专家课堂观摩填报信息成功");
		} catch (Exception e) {
			logger.info("查询专家课堂观摩填报信息失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询专家课堂观摩填报信息失败");
		}
	}
	
	/**
	 * 保存专家课堂观摩信息
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/saveAuthExpertObservation" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> saveAuthExpertObservation(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String> map){
		try {
			
			String userId=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==userId){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			String schoolId=map.get("schoolId");
			String name=map.get("name");
			String classC=map.get("classC");
			String studentAmount=map.get("studentAmount");
			String teacher=map.get("teacher");
			String title=map.get("title");
			String age=map.get("age");
			String classCatagory=map.get("classCatagory");
			String techingSubject=map.get("techingSubject");
			String point1=map.get("point1");
			String point2=map.get("point2");
			String point3=map.get("point3");
			String point4=map.get("point4");
			String point5=map.get("point5");
			String opinion=map.get("opinion");
			String comprehensive=map.get("comprehensive");
			
			AuthObservationEvaluation a=authObservationEvaluationService.queryAuthObservationEvaluationInfo(schoolId, userId);
			if(null==a){
				a=new AuthObservationEvaluation();
			}
			String nowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			a.setSchoolId(schoolId);
			a.setExportId(userId);
			a.setAge(age);
			a.setClassC(classC);
			a.setClassCatagory(classCatagory);
			a.setComprehensive(comprehensive);
			a.setCreateTime(nowTime);
			a.setName(name);
			a.setOpinion(opinion);
			a.setPoint1(point1);
			a.setPoint2(point2);
			a.setPoint3(point3);
			a.setPoint4(point4);
			a.setPoint5(point5);
			a.setStudentAmount(studentAmount);
			a.setTeacher(teacher);
			a.setTitle(title);
			a.setTechingSubject(techingSubject);
			authObservationEvaluationService.saveAuthObservationEvaluationInfo(a);
			return toResponse(null,ReturnCode.SUCCESS,"保存专家课堂观摩信息成功");
		} catch (Exception e) {
			logger.info("保存专家课堂观摩信息失败",e);
			return toResponse(null, ReturnCode.FAIL, "保存专家课堂观摩信息失败");
		}
	}
	
	/*******************************************专家专业技能页面*******************************************************/
	
	/**
	 * 查询专家专业技能列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthExpertTaskPage" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthExpertTaskPage(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String> map){
		try {
			if(StringUtils.isBlank(map.get("pageSize"))||StringUtils.isBlank(map.get("pageNumber"))){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"分页参数不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			Page<ExpertTaskBean> ls=authSchoolService.queryAuthSchoolAndTask(pid, map);
			return toResponse(ls,ReturnCode.SUCCESS,"查询专家专业技能列表成功");
		} catch (Exception e) {
			logger.info("查询专家专业技能列表失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询专家专业技能列表失败");
		}
	}
	
	
	/**
	 * 查询专家对应专业技能抽取的题目
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryExpertExams" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryExpertExams(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String taskId,@RequestParam String groupId){
		try {
			if(StringUtils.isBlank(taskId)||StringUtils.isBlank(groupId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			
			List<AuthExamExpertMap> list=authExamExpertMapService.queryAuthExamExpertMapByTaskAndExpertId(groupId, taskId, pid);
			
			return toResponse(list,ReturnCode.SUCCESS,"查询专家对应专业技能抽取的题目成功");
		} catch (Exception e) {
			logger.info("查询专家对应专业技能抽取的题目失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询专家对应专业技能抽取的题目失败");
		}
	}
	
	/**
	 * 保存专家专业技能测试用表  -必测/选测    其他任务没有
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/saveExpertTask" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> saveExpertTask(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String>map ){
		try {
			String taskId=map.get("taskId");
			String groupId=map.get("groupId");
			String fileUrl=map.get("fileUrl");
			if(StringUtils.isBlank(taskId) //任务id
					||StringUtils.isBlank(groupId) //组id
					||StringUtils.isBlank(fileUrl) //上传文件路径
					){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			AuthExportTaskMap a=authExportTaskMapService.queryAuthExportTaskByGroupAndTaskAndExpertId(groupId, taskId, pid);
			if(null==a){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"专家此条专业技能不存在");
			}
			String name=fileUrl.substring(fileUrl.lastIndexOf("/")+1, fileUrl.length());
			a.setTaskFileUrl(fileUrl);
			a.setTaskFileName(name);
			authExportTaskMapService.saveAuthExpertTaskWord(a);
			return toResponse(null,ReturnCode.SUCCESS,"保存专家专业技能测试用表成功");
		} catch (Exception e) {
			logger.info("保存专家专业技能测试用表失败",e);
			return toResponse(null, ReturnCode.FAIL, "保存专家专业技能测试用表失败");
		}
	}
	
	
	/**
	 * 上传专家 专业技能测试用表
	 * @param Filedata
	 * @return
	 */
	@RequestMapping(value="/uploadTask" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> uploadFile(
			@RequestParam("file")MultipartFile filedata
			){
		try {
			String returnDatasUrl = null;
	  		String datasfile = appconfig.getFilePath();
	  		
	  		//取得可上传的文件类型  
	  		List<String>fileTypes = arrayToList(appconfig.getFileType().split(","));
	  		
	  		String fileName = filedata.getOriginalFilename();  
	  		//获取上传文件类型的扩展名,先得到.的位置，再截取从.的下一个位置到文件的最后，最后得到扩展名  
	  		String ext = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length());  
	  		//对扩展名进行小写转换  
	  		ext = ext.toLowerCase();  
	  		/*//新的文件名
	  		String newFileName = new SimpleDateFormat("yyyyMMddHHmmssms").format(new Date()) + 
	  				(int)(Math.random()*10000) + "." + ext;*/
	  		File file = null;
	  		if(!fileTypes.contains(ext)){
	  			return toResponse(null,ReturnCode.FILE_TYPE_NOT_MATCH,"该文件类型不允许");
	  		}
	  		Long examSize=filedata.getSize();
	  		if(1.0*examSize/1024/1024>appconfig.getFileSize()){
	  			return toResponse(null,ReturnCode.FILE_SIZE_TOO_LONG,"文件大小超出限定上限");
	  		}
	  		
	  		Calendar cal=Calendar.getInstance();
            int y=cal.get(Calendar.YEAR);
            int m=cal.get(Calendar.MONTH)+1;
            int d=cal.get(Calendar.DATE);
            Long nowTime=new Date().getTime();
            String pathbig=datasfile+y+"/"+m+"/"+d+"/"+nowTime+"/"+fileName;
            file=new File(pathbig);
     		if(!file.exists()){
     			file.getParentFile().mkdirs();
     			file.createNewFile();
     		}
     		filedata.transferTo(file);
				
		    returnDatasUrl = y+"/"+m+"/"+d+"/"+nowTime+"/"+fileName;
			return toResponse(returnDatasUrl,ReturnCode.SUCCESS,null);
		} catch (Exception e) {
			logger.error("文件上传失败", e);
			return toResponse(null,ReturnCode.FAIL,"文件上传失败");
		}
	}
	
   private List<String> arrayToList(String[] strs){
    	List<String> list=new ArrayList<String>();
    	if(strs.length>0){
    		for(int a =0;a<strs.length;a++){
    			list.add(strs[a].toString().trim());
    		}
    	}
		return list;
    	
    }
	/**
	 * 下载文档
	 * @param request
	 * @param response
	 * @param map
	 * @return
	 */
	@RequestMapping(value="/downloadFile" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public void downloadFile(HttpServletRequest request,HttpServletResponse response ,@RequestParam String expertTaskId){
		
		try {
			AuthExportTaskMap a=authExportTaskMapService.queryAuthExportTaskMapById(expertTaskId);
			if(null==a){
				return;
			}
			//获取网站部署路径(通过ServletContext对象)，用于确定下载文件位置，从而实现下载  
	        String path = appconfig.getFilePath();  
	        //1.设置文件ContentType类型，这样设置，会自动判断下载文件类型  
	        String filepath= a.getTaskFileUrl();
	        String filename=filepath.substring(filepath.lastIndexOf("/")+1, filepath.length());
	        filename = java.net.URLEncoder.encode(filename, "UTF-8");
	        
	        response.setHeader("Content-Type","application/msexcel");
	        response.setHeader("Content-disposition", String.format("attachment; filename=\"%s\"", filename));
	        response.setContentType("application/vnd.ms-excel;charset=utf-8");
	        ServletOutputStream out;  
	        //通过文件路径获得File对象(假如此路径中有一个download.pdf文件)  
	        File file = new File(path +filepath);  
	  
	            FileInputStream inputStream = new FileInputStream(file);  
	  
	            //3.通过response获取ServletOutputStream对象(out)  
	            out = response.getOutputStream();  
	            
	            byte[] buffer = new byte[512];  
	            int count = 0;
		         while ((count = inputStream.read(buffer)) > 0) {
		        	 out.write(buffer, 0, count);
		         }
	            inputStream.close();  
	            out.close();  
	            out.flush();  
	  
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}   
   
   
   
   
   

/********************************************************一级指标分项考察意见表**************************************/
   
   
	/**
	 * 专家一级指标分项考察意见列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthSchoolOneIndexAndTask" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthSchoolOneIndexAndTask(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String> map){
		try {
			if(StringUtils.isBlank(map.get("pageSize"))||StringUtils.isBlank(map.get("pageNumber"))){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"分页参数不可为空");
			}
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			Page<ExpertTaskBean> ls=authSchoolService.queryAuthSchoolOneIndexAndTask(pid, map);
			return toResponse(ls,ReturnCode.SUCCESS,"专家一级指标分项考察意见列表成功");
		} catch (Exception e) {
			logger.info("专家一级指标分项考察意见列表失败",e);
			return toResponse(null, ReturnCode.FAIL, "专家一级指标分项考察意见列表失败");
		}
	}
	

	/**
	 * 查询专家某一学校一级指标分项考察意见表数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthIinspectionOpinionsLists" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthIinspectionOpinionsLists(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String groupId,@RequestParam String itemId){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			if(StringUtils.isBlank(groupId)||StringUtils.isBlank(itemId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			List<AuthIinspectionOpinions>  ls=authIinspectionOpinionsService.queryAuthIinspectionOpinionsLists(groupId, itemId, pid);
			Map<String,Map<String,String>> m=new HashMap<String, Map<String,String>>();
			Map<String,String>map_a=new HashMap<String, String>();
			Map<String,String>map_b=new HashMap<String, String>();
			Map<String,String>map_c=new HashMap<String, String>();
			for(AuthIinspectionOpinions a:ls){
				if("a".equals(a.getMode())){
					map_a.put(a.getKeys(), a.getValue());
				}
				if("b".equals(a.getMode())){
					map_b.put(a.getKeys(), a.getValue());
				}
				if("c".equals(a.getMode())){
					map_c.put(a.getKeys(), a.getValue());
				}
			}
			m.put("a", map_a);
			m.put("b", map_b);
			m.put("c", map_c);
			return toResponse(m,ReturnCode.SUCCESS,"查询专家某一学校一级指标分项考察意见表数据成功");
		} catch (Exception e) {
			logger.info("查询专家某一学校一级指标分项考察意见表数据失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询专家某一学校一级指标分项考察意见表数据失败");
		}
	}
	
	/**
	 * 根据一级指标查询对应学校的二级指标
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryTwoItemByOneItem" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryTwoItemByOneItem(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String groupId,@RequestParam String itemId){
		try {
			
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			if(StringUtils.isBlank(groupId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			AuthGroup group=authGroupService.queryAuthGroupInfoById(groupId);
			if(null==group){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该现场考察专家组不存在");
			}
			AuthSchool school=authSchoolService.queryAuthSchoolInfoById(group.getSchoolId());
			if(null==school){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该考察组的学校不存在");
			}
			List<AuthItem>list=authItemService.queryAuthItemsByFidAndMajor(itemId, school.getMajor());
			if(list.size()>0){
				for(AuthItem a:list){
					List<AuthItem>l=authItemService.queryAuthItemByFid(a.getPid(),school.getMajor());
					a.setList(l);
				}
			}
			
			return toResponse(list,ReturnCode.SUCCESS,"根据一级指标查询对应学校的二级指标成功");
		} catch (Exception e) {
			logger.info("根据一级指标查询对应学校的二级指标失败",e);
			return toResponse(null, ReturnCode.FAIL, "根据一级指标查询对应学校的二级指标失败");
		}
	}

	/**
	 * 保存专家某一学校一级指标分项考察意见表数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/saveAuthIinspectionOpinionsLists" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> saveAuthIinspectionOpinionsLists(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String>map){
		try {
			String groupId=map.get("groupId");
			String itemId=map.get("itemId");
			String keys=map.get("keys");
			String values=map.get("values");
			String modes=map.get("modes");
			String pid=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			if(StringUtils.isBlank(groupId)||StringUtils.isBlank(itemId)
					||StringUtils.isBlank(keys)||StringUtils.isBlank(values)||StringUtils.isBlank(modes)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			String[] keyList=keys.split(",");
			String[] valueList=values.split(",");
			String[] modeList=modes.split(",");
			List<AuthIinspectionOpinions> list=new ArrayList<AuthIinspectionOpinions>();
			authIinspectionOpinionsService.deleteAuthIinspectionOpinionss(groupId, itemId, pid);
			if(keyList.length>0){
				String nowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				for(int i=0;i<keyList.length;i++){
					AuthIinspectionOpinions a=new AuthIinspectionOpinions();
					a.setKeys(keyList[i]);
					a.setCreateTime(nowTime);
					a.setExpertId(pid);
					a.setGroupId(groupId);
					a.setItemId(itemId);
					a.setValue(valueList[i]);
					a.setMode(modeList[i]);
					list.add(a);
				}
			}
			authIinspectionOpinionsService.saveAuthIinspectionOpinionsInfo(list);
			return toResponse(null,ReturnCode.SUCCESS,"保存专家某一学校一级指标分项考察意见表数据成功");
		} catch (Exception e) {
			logger.info("保存专家某一学校一级指标分项考察意见表数据失败",e);
			return toResponse(null, ReturnCode.FAIL, "保存专家某一学校一级指标分项考察意见表数据失败");
		}
	}

	
/***********************************************组长：认证报告*****************/
	/**
	 * 分页查询报告
	 * @param request
	 * @param response
	 * @param map
	 * @return
	 */
	@RequestMapping(value="/queryAuthExportReport" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthExportReport(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String>map){
		try {
			String pId=(String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pId)
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			String pageSize = map.get("pageSize");
			String pageNumber = map.get("pageNumber");
			if(StringUtils.isBlank(pageSize)||StringUtils.isBlank(pageNumber)){
				return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "参数存在空值");
			}
			AuthExportGroupMap aa = authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pId);
			if(null==aa||!"2".equals(aa.getIdentitys())){
				return toResponse(null,ReturnCode.USER_IDENTITY_NOT_MATCH,"非现场考察联络员不可进行此操作");
			}
			map.put("groupId", aa.getGroupId());
			Page<AuthGroup> page = authExportGroupMapService.queryAuthGroupInfoByPage(map);
			return toResponse(page,ReturnCode.SUCCESS,"查询信息成功");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null,ReturnCode.SUCCESS,"查询信息成功");
		}
	}
	
	/**
	 * 下载认证报告
	 * @param request
	 * @param response
	 * @param map
	 * @return
	 */
	@RequestMapping(value="/downloadReport" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public void downloadReport(HttpServletRequest request,HttpServletResponse response ,@RequestParam String pid){
		
		try {
			/*pid = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null==pid)
				return;*/
			AuthGroup ag = authGroupService.queryAuthGroupInfoById(pid);
			//获取网站部署路径(通过ServletContext对象)，用于确定下载文件位置，从而实现下载  
	        String path = appconfig.getFilePath();  
	        //1.设置文件ContentType类型，这样设置，会自动判断下载文件类型  
	        response.setContentType("multipart/form-data");  
	        //2.设置文件头：最后一个参数是设置下载文件名(假如我们叫a.pdf) 
	        String filepath= ag.getReportName();
	        if(null == filepath){
	        	return;
	        }
	        String filename=filepath.substring(filepath.lastIndexOf("/")+1, filepath.length());
	        response.setHeader("Content-Disposition", "inline; filename="  
	                + new String(filename.getBytes("utf-8"), "ISO-8859-1"));  
	        ServletOutputStream out;  
	        //通过文件路径获得File对象(假如此路径中有一个download.pdf文件)  
	        File file = new File(path +filepath);  
	  
	            FileInputStream inputStream = new FileInputStream(file);  
	  
	            //3.通过response获取ServletOutputStream对象(out)  
	            out = response.getOutputStream();  
	            
	            byte[] buffer = new byte[512];  
	            int count = 0;
		         while ((count = inputStream.read(buffer)) > 0) {
		        	 out.write(buffer, 0, count);
		         }
	            inputStream.close();  
	            out.close();  
	            out.flush();  
	  
		} catch (Exception e) {
			e.printStackTrace();
		}
	
	}
	
	/**
	 * 保存报告名与路径
	 */
	@RequestMapping(value = "/saveAuthReportInfo" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> saveAuthReportInfo(HttpServletRequest request,@RequestBody Map<String,String> map) throws SQLException{
		
		try{
			String pid = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
			if(null == pid){
				return toResponse(null,ReturnCode.NOLOGIN,"未登录");
			}
			String url=map.get("reportUrl");
			if(StringUtils.isBlank(url)){
				return toResponse(null, ReturnCode.PARAMETER_NOT_NULL, "专业技能项目用表路径不能为空");
			}
			String nowTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			AuthExportGroupMap aa = authExportGroupMapService.queryAuthExportGroupMapByExpertId2("1",pid);
			String groupId = aa.getGroupId();
			AuthGroup ag= authGroupService.queryAuthGroupInfoById(groupId);
			
			//ag.setName(name);
			String filename=url.substring(url.lastIndexOf("/")+1, url.length());
			ag.setReportName(filename);
			ag.setReportUrl(url);
			ag.setUpdateTime(nowTime);
			ag.setCreateTime(ag.getCreateTime());
			
			
			authExportGroupService.saveAuthExportGroupInfo(ag);
			return toResponse(null, ReturnCode.SUCCESS, "报告保存成功");
		}catch(Exception e){
			logger.info("报告保存成功", e);
			return toResponse(null,ReturnCode.FAIL,"报告保存失败");
		}
	}
	
	/******************************************************************填报数据查询********************************************************************************************/
	
	/**
	 * 填报数据查询(绑定)
	 */
	@RequestMapping(value = "/queryAuthObservationSchool" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthObservationSchool(HttpServletRequest request,HttpServletResponse response,@RequestBody Map<String, String> map){
		String expertId = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		if(null == expertId){
			return toResponse(null,ReturnCode.NOLOGIN,"未登录");
		}
		String pageSize = map.get("pageSize");
		String pageNumber = map.get("pageNumber");
		if(StringUtils.isBlank(pageNumber) || StringUtils.isBlank(pageSize)){
			return toResponse(null, ReturnCode.FAIL, "参数存在空值!");
		}
		try {
			Page<AuthSchool> page = authExportGroupService.queryAuthObservationSchool(expertId, map);
			return toResponse(page, ReturnCode.SUCCESS, "查询成功!");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null, ReturnCode.SUCCESS, "查询失败!");
		}
		
	}
	
	/***************************************************************材料评审结果***********************************************************************************************/
	
	/**
	 * 材料评审结果
	 */
	@RequestMapping(value = "/queryAuthmaterialResult" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthmaterialResult(HttpServletRequest request,HttpServletResponse response,@RequestBody Map<String, String> map){
		String expertId = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		if(null == expertId){
			return toResponse(null,ReturnCode.NOLOGIN,"未登录");
		}
		try {
			AuthSchool as = authExportGroupService.querySchoolIdByExpertId(expertId);
			String schoolid = as.getPid();
			MeterialResultBean mrb = new MeterialResultBean();
			List<AuthItem> list = authExportGroupService.queryAuthmaterialResultBySchoolId(schoolid);
			mrb.setSchoolId(schoolid);
			mrb.setSchoolName(as.getSchoolName());
			mrb.setMajor(as.getMajor());
			mrb.setGroupId(as.getGroupId());
			mrb.setList(list);
			mrb.setIsfollow(as.getIsfollow());
			return toResponse(mrb, ReturnCode.SUCCESS, "查询成功!");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null, ReturnCode.FAIL, "查询失败!");
		}
	}
	
	/**
	 * 材料汇总表--汇总
	 */
	@RequestMapping(value = "/queryAuthCollect1" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthCollect1(HttpServletRequest request,@RequestParam String schoolId){
		
		try {
			List<AuthItem> list = new ArrayList<AuthItem>();
			list = authItemService.queryAuthItemTwice("0");
			List<AuthItem> list1 = new ArrayList<AuthItem>();
			for (AuthItem authItem : list) {
				authItem.setList(authItemService.queryAuthCollect(schoolId, authItem.getPid()));
				list1.add(authItem);
			}
			
			return toResponse(list1, ReturnCode.SUCCESS, "查询成功!");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null, ReturnCode.SUCCESS, "查询失败!");
		}
	}

	/**
	 * 现场考察联络员汇总	
	 */
	@RequestMapping(value = "/queryAuthCollectObservation" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthCollectObservation(HttpServletRequest request,HttpServletResponse response,@RequestBody Map<String, String> map){
		String expertId = (String) request.getSession().getAttribute(SessionUser.SESSION_USER_KEY);
		if(null == expertId){
			return toResponse(null,ReturnCode.NOLOGIN,"未登录");
		}
		try {
			AuthExportGroupMap eg = authExportGroupMapService.querygroupIdByExpertId(expertId);
			String groupId = eg.getGroupId();
			
			List<AuthItem> list = new ArrayList<AuthItem>();
			list = authItemService.queryAuthItemTwice("0");
			Map<String,Map<String,String>> m=new HashMap<String, Map<String,String>>();
			List<Map<String,Map<String,String>>> lt = new ArrayList<Map<String,Map<String,String>>>();
			for (int i = 0; i < list.size(); i++) {
				List<AuthIinspectionOpinions>  ls=authIinspectionOpinionsService.queryAuthIinspectionOpinions(groupId, list.get(i).getPid());
				Map<String,String>map_b=new HashMap<String, String>();
				map_b.put(list.get(i).getNumber(), list.get(i).getContent());
				for(AuthIinspectionOpinions a:ls){
					if("b".equals(a.getMode())){
						map_b.put(a.getKeys(), a.getValue());
					}
				}
				m.put(list.get(i).getNumber(), map_b);
			}
			lt.add(m);
			return toResponse(lt, ReturnCode.SUCCESS, "查询成功!");
		} catch (SQLException e) {
			e.printStackTrace();
			return toResponse(null, ReturnCode.FAIL, "查询失败!");
		}
		
	}
	
	/**********************************现场考察结果查看***************************************/
	
	/**
	 * 专家一级指标分项考察意见列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthSchoolOneIndexAndTaskByLeader" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthSchoolOneIndexAndTaskByLeader(HttpServletRequest request,HttpServletResponse response,
			@RequestBody Map<String,String> map){
		try {
			if(StringUtils.isBlank(map.get("pageSize"))||StringUtils.isBlank(map.get("pageNumber"))){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"分页参数不可为空");
			}
			String expertId=map.get("expertId");
			
			Page<ExpertTaskBean> ls=authSchoolService.queryAuthSchoolOneIndexAndTask(expertId, map);
			return toResponse(ls,ReturnCode.SUCCESS,"专家一级指标分项考察意见列表成功");
		} catch (Exception e) {
			logger.info("专家一级指标分项考察意见列表失败",e);
			return toResponse(null, ReturnCode.FAIL, "专家一级指标分项考察意见列表失败");
		}
	}
	
	/**
	 * 查询专家某一学校一级指标分项考察意见表数据
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryAuthIinspectionOpinionsListsByleader" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryAuthIinspectionOpinionsListsByleader(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String groupId,@RequestParam String itemId,@RequestParam String expertId){
		try {
			
			if(null==expertId){
				return toResponse(null,ReturnCode.NOLOGIN,"该专家身份错误");
			}
			if(StringUtils.isBlank(groupId)||StringUtils.isBlank(itemId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			List<AuthIinspectionOpinions>  ls=authIinspectionOpinionsService.queryAuthIinspectionOpinionsLists(groupId, itemId, expertId);
			Map<String,Map<String,String>> m=new HashMap<String, Map<String,String>>();
			Map<String,String>map_a=new HashMap<String, String>();
			Map<String,String>map_b=new HashMap<String, String>();
			Map<String,String>map_c=new HashMap<String, String>();
			for(AuthIinspectionOpinions a:ls){
				if("a".equals(a.getMode())){
					map_a.put(a.getKeys(), a.getValue());
				}
				if("b".equals(a.getMode())){
					map_b.put(a.getKeys(), a.getValue());
				}
				if("c".equals(a.getMode())){
					map_c.put(a.getKeys(), a.getValue());
				}
			}
			m.put("a", map_a);
			m.put("b", map_b);
			m.put("c", map_c);
			return toResponse(m,ReturnCode.SUCCESS,"查询专家某一学校一级指标分项考察意见表数据成功");
		} catch (Exception e) {
			logger.info("查询专家某一学校一级指标分项考察意见表数据失败",e);
			return toResponse(null, ReturnCode.FAIL, "查询专家某一学校一级指标分项考察意见表数据失败");
		}
	}
	
	/**
	 * 根据一级指标查询对应学校的二级指标
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/queryTwoItemByOneItemByleader" ,produces = MediaType.TEXT_HTML_VALUE+";charset=UTF-8", method=RequestMethod.GET)
	@ResponseBody
	public ResponseEntity<String> queryTwoItemByOneItemByleader(HttpServletRequest request,HttpServletResponse response,
			@RequestParam String groupId,@RequestParam String itemId,@RequestParam String expertId){
		try {
			
			if(null==expertId){
				return toResponse(null,ReturnCode.NOLOGIN,"该专家身份错误");
			}
			if(StringUtils.isBlank(groupId)){
				return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"参数存在空值");
			}
			AuthGroup group=authGroupService.queryAuthGroupInfoById(groupId);
			if(null==group){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该现场考察专家组不存在");
			}
			AuthSchool school=authSchoolService.queryAuthSchoolInfoById(group.getSchoolId());
			if(null==school){
				return toResponse(null,ReturnCode.USERINFO_NOT_EXIST,"该考察组的学校不存在");
			}
			List<AuthItem>list=authItemService.queryAuthItemsByFidAndMajor(itemId, school.getMajor());
			if(list.size()>0){
				for(AuthItem a:list){
					List<AuthItem>l=authItemService.queryAuthItemByFid(a.getPid(),school.getMajor());
					a.setList(l);
				}
			}
			
			return toResponse(list,ReturnCode.SUCCESS,"根据一级指标查询对应学校的二级指标成功");
		} catch (Exception e) {
			logger.info("根据一级指标查询对应学校的二级指标失败",e);
			return toResponse(null, ReturnCode.FAIL, "根据一级指标查询对应学校的二级指标失败");
		}
	}
		
}
